package com.anmory;

import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RequestController {
    @RequestMapping("/request")
    public String request(HttpServletRequest request) {
        // 获取请求方法
        String method = request.getMethod();
        System.out.println("请求方法：" + method);

        // 获取请求路径
        String requestURI = request.getRequestURI();
        System.out.println("请求路径：" + requestURI);

        // 获取请求参数
        String name = request.getParameter("name");
        System.out.println("请求参数：" + name);

        // 获取请求头信息
        String userAgent = request.getHeader("User-Agent");
        System.out.println("请求头信息：" + userAgent);
        return "请求方法：" + method + "<br/>" +
                "请求路径：" + requestURI + "<br/>" +
                "请求参数：" + name + "<br/>" +
                "请求头信息：" + userAgent;
    }
}
